home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************
- * TEXTRA-AREXX script -- Mike Haas, 1993, Public Domain *
- * *
- * For use with TEXTRA, the GUI-based Amiga Text Editor. *
- * *
- * If you enhance or write your own Textra scripts, please send *
- * to me... especially if you want them added to the package. *
- *******************************************************************/
-
- /*
- ** MarkCFuncs.textra
- **
- ** This script is handy for C programmers.
- ** It requires version 1.15, rexx level 7, of Textra.
- **
- ** It will find, highlight and mark all c function declarations in
- ** a file.
- **
- ** It will think there is a declaration if there is at least a '('
- ** char on the line AND the text is not indented at all (begins
- ** in the first column). It also checks that there is a '{' character
- ** within the next 10 lines. (vary the MAX_HEADER_LINES value
- ** to increase this. 10 lines SHOULD suffice for the huge majority
- ** of functions). If these conditions are met, the word
- ** occurring before the '(' character in MARKed as itself().
- **
- ** This approach is not foolproof, but it will
- ** mark the functions in most of the C code I've ever seen to
- ** a high degree of accuracy. The only mistakes I've seen it
- ** make is to occasionally MARK something that wasn't a
- ** function, such as part of a comment line that has a set of
- ** parenthesis in it.
- **
- ** Especially useful when assigned to a Textra Function
- ** key or CTRL-key macro.
- **
- ** Mike Haas, Nov 8, 1993
- **
- ** This program is hereby placed in the public domain.
- **
- */
-
- options results
-
- /*check Textra version, must be rexx level 7 at least for MARKSELECT */
- rex = 0; result = "NOTSUPPORTED"
- address 'TEXTRA' 'textraversion'
- parse var result maj min rex
- if (result == "NOTSUPPORTED") | (rex < 7) then do
- address 'TEXTRA' 'notify "This version of Textra cannot run this script."'
- exit
- end
-
- /*save hopselect state*/
- prefs AlphanumericHops read; hss = result
- prefs AlphanumericHops ON
-
- MAX_HEADER_LINES = 10
-
- done = 0
-
- gotoxy 0 0
-
- do while (done == 0)
-
- checkcancel
- if (result == CANCEL) then do
- prefs AlphanumericHops hss /*restore saved state*/
- exit
- end
-
- find "("
- if result == "OK" then do
-
- get select position
- parse var result stx' 'sty' 'enx' 'eny
-
- gotoxy 0 sty
- get cursor char
- if ((result ~= ' ') & (result ~= ' '/* tab */) & (result ~= '#')) then do
-
- isfunc = 0
- find "{"
- if (result == "OK") then do
- get select position; parse var result bstx bsty zx zy
- if ((sty+MAX_HEADER_LINES) > bsty) then
- isfunc = 1
- end
-
- if (isfunc == 1) then do
- gotoxy stx+1 sty
- hopselect prev word
- get select text; parse var result zero' 'thename
- thename = thename"()"
- markselect thename
-
- /*
- Uncomment the next line if you want this script
- to exit after finding and marking one function.
- */
-
- /* done = 1 */
-
- end
- end
-
- gotoxy 0 sty+1
-
- end
- else
- done = 1
-
- end
-
- /*restore saved state*/
- prefs AlphanumericHops hss
-
-